package cn.hesion.springbootmq.controller;
/**
 * ClassName: MQProducerController <br/>
 * Description: <br/>
 * date: 2021/11/10 9:48<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 生产者测试接口
 * @author: hesion
 * @create: 2021-11-10 09:48
 **/
@Slf4j
@RestController
public class MQProducerController {


@Autowired
    RocketMQTemplate rocketMQTemplate;

    /**
     * 消息过滤，发送tag消息
     */
    @RequestMapping("/send/tag/{tag}")
    public String tag(@PathVariable("tag") String tag) {
        SendResult sendResult = rocketMQTemplate.syncSend("springboot-mq:"+tag, "Hello,"+tag, 30 * 1000);
        log.info("sendResult:"+sendResult);
        return sendResult.toString();
    }


}
